home *** CD-ROM | disk | FTP | other *** search
- #include "VCRplus.h"
- #define ScreenDepth(gdh) ((*((*gdh)->gdPMap))->pixelSize)
- #define dragscreenmargin 4 /*for dragging windows, leave this many pixels on all sides*/
-
- extern DialogPtr theDialog;
- extern unsigned long myFreeMem;
-
- short doDlgEvt(EventRecord *evp)
- {
- DialogPtr whichDlg;
- short itemHit;
- char theKey;
- Rect myPaletteRect;
- Point whichColor;
-
- if (DialogSelect( evp, &whichDlg, &itemHit ) == FALSE )
- return(0); // no extra work needed , just return
-
- if ( evp->what == keyDown )
- {
- if ( evp->modifiers & cmdKey )
- { /*command key pressed */
- theKey = evp->message & charCodeMask;
- switch (theKey)
- {
- case 'C': // copy
- case 'c':
- SelIText(theDialog, ((DialogPeek)theDialog)->editField +1, 0, 32767); // select all the text
- DlgCopy(theDialog);
- ZeroScrap();
- TEToScrap();
- myFreeMem = Min(MaxBlock(), myFreeMem);
- break;
- case 'Q': // quit
- case 'q':
- ExitToShell();
- break;
- case 'A': // Select All
- case 'a':
- SelIText(theDialog, ((DialogPeek)theDialog)->editField +1, 0, 32767); // select all the text
- break;
- }
- return(0);
- /* don't let unwanted command-keys into DialogSelect() */
- }
- return(0);
- }
-
- if (DialogSelect( evp, &whichDlg, &itemHit ) == FALSE )
- return(0); // no extra work needed , just return
-
- if ( whichDlg == theDialog ) // process the interaction
- {
- switch ( itemHit )
- {
- case ok:
- ExitToShell(); // user said to "DO IT"
- break;
- case dlgENCODER: // encode button
- if (validateEntry(ENCODE))
- encoder();
- else
- SysBeep(3);
- break;
- case dlgDECODER: // decode button
- if (validateEntry(DECODE))
- decoder();
- else
- SysBeep(3);
- break;
- } /* end of switch */
- }
- }
-
- void handledrag (EventRecord ev, WindowPtr w)
- {
-
- Rect r;
-
- r = screenBits.bounds;
- r.top = r.top + MBarHeight; /*access a QuickDraw global*/
- r.left = r.left + dragscreenmargin;
- r.right = r.right - dragscreenmargin;
- r.bottom = r.bottom - dragscreenmargin;
- DragWindow (w, ev.where, &r);
- }
-
-
- int handlemouse (EventRecord ev)
- {
-
- register short whichPart;
- WindowPtr w;
- Boolean isTrue;
-
- whichPart = FindWindow (ev.where, &w);
-
- if (w != nil)
-
- if (w != FrontWindow ()) /*just like all other Mac programs*/
- {
- SelectWindow (w);
- return; /*the mouse click is consumed by the bringtofront operation*/
- }
-
- switch (whichPart)
- {
- case inSysWindow:
- SystemClick (&ev, w);
- break;
-
- case inMenuBar:
- return(DoCommand(MenuSelect(ev.where)));
- break;
-
- case inDrag:
- handledrag (ev, w);
- break;
-
- case inGoAway:
- isTrue = TrackGoAway (w, ev.where);
- if (isTrue)
- ExitToShell();
- break;
-
- } /*switch*/
- } /*handlemouse*/
-
-
-
- int DoCommand(long mResult)
- {
- int theItem;
- Str255 name;
-
- theItem = LoWord(mResult);
- switch (HiWord(mResult))
- {
- case appleID:
- GetItem(GetMHandle(appleID), theItem, &name);
- if (theItem == 1)
- Alert(128,0L);
- else
- {
- OpenDeskAcc(name);
- SetPort(theDialog);
- }
- break;
-
- case fileID:
- ExitToShell();
- break;
-
- case editID:
- if (SystemEdit(theItem-1) == 0)
- {
- switch (theItem)
- {
- case cutCommand:
- DlgCut(theDialog);
- break;
-
- case copyCommand:
- SelIText(theDialog, 3, 0, 32767); // select all the text
- DlgCopy(theDialog);
- ZeroScrap();
- TEToScrap();
- break;
-
- case pasteCommand:
- DlgPaste(theDialog);
- break;
-
- case clearCommand:
- DlgDelete(theDialog);
- break;
-
- case selectCommand:
- SelIText(theDialog, 3, 0, 32767); // select all the text
- break;
- }
- }
- break;
- }
- HiliteMenu(0);
- return(1);
- }
-